package com.socialnetwork.util;

public class UtilFormat {

	private UtilFormat() {
	}
	
	public static String formatNameController(String servletPath){
		//EXAMPLE = /LoginController.action >> LoginController
		
		String controller = "";
		if(servletPath != null){
			//remove the '/' of name controller
			controller = servletPath.replace("/", "");
			//remove the '.action' of name controller
			controller = controller.replace(".action", "");
		}
		
		//return name real of controller
		return controller;
	}
	
	public static String formatUrlPath(String url, String queryParameters){
		
		String urlRedirect = "";
		
		if(url != null && !url.equals("")){
			urlRedirect += url;
			if(queryParameters != null && !queryParameters.equals("")){
				urlRedirect += "?" + queryParameters;
			}
		}
		
		return urlRedirect;
		
	}
	
	

}
